﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SellerProject.testfolder
{
    public partial class confirm_Y_continue_frompost : System.Web.UI.Page
    {
        private Dictionary<bool, Action> dic;

        protected void Page_Load(object sender, EventArgs e)
        {
            string value = Request.Form["hName"] ?? "";

            bool result;

            if (bool.TryParse(value, out result))
            {
                dic = new Dictionary<bool, Action>();

                dic.Add(true, Confirm);
                dic.Add(false, Cancel);

                dic[result]();
            }
        }
        protected void btnCallBack_Click(object sender, EventArgs e)
        {
            // 先执行一段代码  
            lit.Text = DateTime.Now.ToString("yyyy-MM-dd");


            //弹出confirm  
            for (int i = 0; i < 5; i++)
            {
                lit.Text += i + "</br>";
                if (i == 4)
                {
                    //ClientScript.RegisterStartupScript(GetType(), "confirm", "CustomSubmit();", true);
                    ScriptManager.RegisterStartupScript(this, GetType(), "confirm", "CustomSubmit();", true);
                    return;
                } 
            }
            lit.Text += "\n loop over";
        }

        //确认时执行的代码  
        private void Confirm()
        {
            lit.Text = "确认";
        }

        //取消时执行的代码  
        private void Cancel()
        {
            lit.Text = "取消";
        }  


    }
}